<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="table-scrollable">
	<table class="table table-striped table-hover table-info">
		<thead>
			<tr>
				<th>#</th>
				<th>代码</th>
				<th>账户名</th>
				<th>店铺名</th>
				<th>店铺状态</th>
				<th>数据同步</th>

				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.result}" var="account" varStatus="vs">
				<tr>
					<td>${vs.count + page.offset}</td>
					<td>${account.code}</td>
					<td>${account.name}</td>
					<td>${account.shopname}</td>
					<td>${account.username}</td>
					<td><a
						onclick="synchronization('${account.platformId}','${account.id}')"><c:if
								test="${account.platformId=='1'}">eBay数据同步</c:if> <c:if
								test="${account.platformId=='2'}">亚马逊数据同步</c:if></a></td>

					<td><a href="javascript:;" class="btn btn-sm blue"
						onclick="update('/account/account?id=${account.id}')"> <i
							class="fa fa-edit"></i>编辑
					</a> <a href="javascript:;" class="btn btn-sm red"
						onclick="del('/account/delete?id=${account.id}')"> <i
							class="fa fa-trash"></i>删除
					</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="pageination-panel">${page}</div>

<div class="modal fade" id="menuModal" tabindex="-1" role="basic"
	aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true"></button>
				<h4 class="modal-title">新建账号</h4>
			</div>
			<div class="modal-body">
				<div style="margin: 0 auto; padding: 3% 3% 3% 5%;">
					<span>店铺名称</span><input type="text"
						style="width: 200px; margin-left: 20px;" /><br> <br> <span>账号平台</span>
					<input type="text" style="width: 200px; margin-left: 12px;" />
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn blue" onclick="addP()">添加</button>
				<button type="button" class="btn blue" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function synchronization(platformId, accountid) {

		if (platformId == '1') {

			$.ajax({
				type : 'post',
				url : webRoot + '/webpage/shopping/Amazon/jdt.jsp',
				dataType : 'html',
				success : function(data) {
					$(".panel-content").html(data);
				}
			});

			$.ajax({
				type : 'post',
				url : webRoot + '/ordert/synchronization',
				data : {
					"id" : accountid
				},
				dataType : 'json',
				success : function(data) {


					if (data.para == 1) {

						synchronization(1, data.accountid);
					} else {
						alert("订单同步完成")
						search()
					}

	
				}
			});

		}

		if (platformId == '2') {

			$.ajax({
				type : 'post',
				url : webRoot + '/webpage/shopping/Amazon/jdt.jsp',
				dataType : 'html',
				success : function(data) {
					$(".panel-content").html(data);
				}
			});

			$.ajax({
				type : 'post',
				url : webRoot + '/amazonorderslists/synchronization',
				data : {
					"id" : accountid
				},
				dataType : 'json',
				success : function(data) {
					
					
					if (data.para == 1) {

						synchronization(2, data.accountid);
					} else {
						alert("订单同步完成")
						search()
					}


				}
			});

		}

	}
</script>